﻿@model Online_Course.Domain.SysUser
@using Online_Course.Web.Apps
@{
    Layout = null;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>注册</title>
    <link rel="stylesheet" href="/css/style.css" />
    </head>

<body style="background:url(/Images/3.jpg);background-size:100% 100%;background-repeat:no-repeat;background-attachment:fixed;">
    <div class="register-container">
        <h1>高校选修课选课系统注册</h1>

        <div class="connect">
            <p>Link the world. Share to world.</p>
        </div>

        <div>
            <div>
                <input type="text" id="username" name="username" class="username" placeholder="您的用户名" autocomplete="off" />
            </div>
            <div>
                <input type="text" id="stucode" name="stucode" class="stucode" placeholder="学号" autocomplete="off" />
            </div>
            <div>
                <input type="password" id="password" name="password" class="password" placeholder="输入密码" oncontextmenu="return false" onpaste="return false" />
            </div>
            <div>
                <input type="password" id="confirm_password" name="confirm_password" class="confirm_password" placeholder="再次输入密码" oncontextmenu="return false" onpaste="return false" />
            </div>
            <div>
                <input type="text" id="number" name="number" class="number" placeholder="输入手机号码" autocomplete="off" />
            </div>
            <button id="submit" type="submit">注 册</button>
        </div>

        <a href="Login">
            <button type="button" class="register-tis">已经有账号？</button>
        </a>

    </div>

    <script src="/js/jquery.min.js"></script>
    <script src="/js/common.js"></script>
    <!--背景图片自动更换-->
    <script src="/js/supersized.3.2.7.min.js"></script>
    <script src="/js/supersized-init.js"></script>
    <!--表单验证-->
    <script src="/js/jquery.validate.min.js?var1.14.0"></script>


    <script type="text/javascript">
        $(function () {
            $("#submit").click(function () {
                var username = $("#username").val();
                var stucode = $("#stucode").val();
                var password = $("#password").val();
                var confirm_password = $("#confirm_password").val();
                var number = $("#number").val();
                if ($.trim(username).length < 1) {
                    alert("用户名不能为空");
                    $("[name='username']").focus();
                    return false;
                }
                if ($.trim(stucode).length < 1)
                {
                    alert("学号不能为空");
                    $("#stucode").focus();
                    return false;
                }
                if ($.trim(password).length < 1) {
                    alert("密码不能为空");
                    $("[name='password']").focus();
                    return false;
                }
                if ($.trim(number).length < 11)
                {
                    alert("手机号格式错误，请输入至少11位数的手机号！");
                    $("#number").focus();
                    return false;
                }
                data = {
                    "username": username,
                    "stucode": stucode,
                    "password": password,
                    "confirm_password": confirm_password,
                    "number": number,
                }
                $.ajax({
                    url: "/SysUser/Register",
                    type: "post",
                    data: data,
                    success: function (data) {
                        if (data != "true") {
                                if (data == "1") {
                                    alert("密码与确认密码不相等!请重新输入");
                                    $("#password").focus();
                                }
                                else
                                    if (data == "0") {
                                        alert("用户名密码或学号长度<3,请重新输入");
                                        $("#username").focus();
                                    }
                        }
                        else {
                            alert("恭喜同学!注册成功，登录账号是你注册的学号！");
                            $(location).attr("href", "/SysUser/Login");
                        }
                    }
                })
            })
        }
        )
    </script>





</body>

   
</html>

